package com.tt.fashionWebSite.dao.jpa;

import com.tt.fashionWebSite.dao.SizeQuanTuVanDao;
import com.tt.fashionWebSite.domain.SizeQuanTuVan;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by PC on 11/28/14.
 */
@Repository("sizeQuanTuVan")
public class SizeQuanTuVanJpaDao extends GenericJpaDao<SizeQuanTuVan,String> implements SizeQuanTuVanDao {
    public SizeQuanTuVanJpaDao(){
        super(SizeQuanTuVan.class);
    }

    @Override
    public SizeQuanTuVan getInfoByUser(String maTV, String gender) {
       List<SizeQuanTuVan> sizeQuanTuVans = getEntityManager().createNamedQuery(SizeQuanTuVan.GET_INFO_BY_USER, SizeQuanTuVan.class)
              .setParameter("maTV", maTV)
              .setParameter("gender", gender)
              .getResultList();
       if(sizeQuanTuVans != null && sizeQuanTuVans.size() > 0) {
          return sizeQuanTuVans.get(0);
       }
       return null;
    }
}
